const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');



const rules = require('./config/rules');


module.exports = {
    entry: {
        a:'./src/index.js'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    module: rules,
    devServer: {
        contentBase: path.resolve(__dirname, 'dist'),
        host: 'localhost',
        port: 8099,
        open: true,
        hot: true
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        // new webpack.optimize.AggressiveSplittingPlugin({
        //     minSize: 30000, // 字节，分割点。默认：30720
        //     maxSize: 50000, // 字节，每个文件最大字节。默认：51200
        //     chunkOverhead: 0, // 默认：0
        //     entryChunkMultiplicator: 1, // 默认：1
        // }),
        new HtmlWebpackPlugin({
            template: './src/index.html'
        }),
        new CopyWebpackPlugin([{
            from: path.resolve(__dirname, 'src/assets'),
            to: './assets'
        }]),
    ]
};